home *** CD-ROM | disk | FTP | other *** search
- unit ActionLessAppU;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TForm1 = class(TForm)
- edtEntry: TEdit;
- Label1: TLabel;
- lstEntries: TListBox;
- btnAddString: TButton;
- procedure btnAddStringClick(Sender: TObject);
- procedure edtEntryChange(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.btnAddStringClick(Sender: TObject);
- begin
- lstEntries.Items.Add( Trim( edtEntry.Text ) );
- //Give focus back to edit
- edtEntry.SetFocus;
- //Highlight edit contents so it can be replaced by overtyping
- edtEntry.SelectAll;
- //Trigger edit's OnChange to ensure button
- //is enabled or disabled as appropriate
- edtEntry.OnChange( edtEntry )
- end;
-
- procedure TForm1.edtEntryChange(Sender: TObject);
- begin
- btnAddString.Enabled :=
- ( Length( Trim( edtEntry.Text ) ) > 0 ) and
- ( lstEntries.Items.IndexOf( Trim( edtEntry.Text ) ) = -1 )
- end;
-
- end.
-